
import time

from Common.basepage import BasePage
from Common.dir_config import file_dir
from PageLocators.TS.ts_student_detail_loc import StudentDetailLocator
from TestDatas.TsDatas.ts_test_datas import *


class TSCramLesson(BasePage):
    """
    学员补课/退班流程
    """
    def enter_stuDetail(self, stu_num=stu_num_data):
        """
        进入学员详情
        """
        self.input_text(StudentDetailLocator.stuNumInput_loc, "输入学号", stu_num)
        self.click_element(StudentDetailLocator.searchButton_loc, "搜索")
        time.sleep(2)
        self.click_element(StudentDetailLocator.clickEnglishName_loc, "点击选中的学员")
        time.sleep(3)
        self.click_element(StudentDetailLocator.clickMoreInfo_loc, "进入学员详情")
        time.sleep(5)
        student_info_data = self.get_element_text(StudentDetailLocator.studentInfo_loc, "获取学员详情页面学员基本信息")
        return student_info_data

    def cram_lesson(self, class_code=class_code_data, cram_class_code=cram_class_code_data,
                    cram_reason=cram_reason_data):
        """
        补课流程
        """
        self.click_element(StudentDetailLocator.selectCourseStatus_loc, "其他信息-班级-班级状态下拉框")
        self.click_element(StudentDetailLocator.selectFinishStatus_loc, "其他信息-班级-班级状态-选择已结课")
        class_list_data = self.get_element_text(StudentDetailLocator.classList_loc, "获取班级列表的数据")
        self.click_element(StudentDetailLocator.classCodeInput_loc, "其他信息-班级-班级编号输入框", class_code)
        self.click_element(StudentDetailLocator.searchIcon_loc, "其他信息-班级-点击搜索按钮")
        time.sleep(2)
        self.click_element(StudentDetailLocator.listCramLesson_loc, "点击补课按钮")
        time.sleep(2)
        self.click_element(StudentDetailLocator.popupCramLesson_loc, "插班补课弹窗-对应课时的补课按钮")
        self.click_element(StudentDetailLocator.popupClassCodeInput_loc, "插班补课弹窗-搜索要补入的班级编号", cram_class_code)
        self.click_element(StudentDetailLocator.popupSearchButton_loc, "插班补课弹窗-点击搜索按钮")
        self.click_element(StudentDetailLocator.popupSelectIcon_loc, "插班补课弹窗-选择要补课的课时")
        self.click_element(StudentDetailLocator.popupCramLessonReason_loc, "插班补课弹窗-填写补课原因", cram_reason)
        self.click_element(StudentDetailLocator.popupConfirmButton_loc, "插班补课弹窗-点击确认按钮")
        time.sleep(3)
        return class_list_data

    def quit_class(self, class_code=quit_class_code_data):
        """
        退班流程
        """
        self.click_element(StudentDetailLocator.selectCourseStatus_loc, "其他信息-班级-班级状态下拉框")
        self.click_element(StudentDetailLocator.selectFinishStatus_loc, "其他信息-班级-班级状态-选择已结课")
        self.click_element(StudentDetailLocator.classCodeInput_loc, "其他信息-班级-班级编号输入框", class_code)
        self.click_element(StudentDetailLocator.searchIcon_loc, "其他信息-班级-点击搜索按钮")
        time.sleep(2)
        self.click_element(StudentDetailLocator.quitClass_loc, "点击退班按钮")
        self.click_element(StudentDetailLocator.quitReason_loc, "勾选退费原因")
        self.click_element(StudentDetailLocator.communicateScreenshot_loc, "退费沟通截图")
        time.sleep(2)
